package com.student.action;

import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.student.util.excel.ExcelExpUtil;
import com.student.util.excel.ExcelModule;
import com.student.util.excel.ExcelPathUtil;

@Component("SuperAction")
@Scope("prototype")
public class TestAction extends SuperAction {
	private InputStream excelInput;

	public InputStream getExcelInput() {
		return excelInput;
	}
	public void setExcelInput(InputStream excelInput) {
		this.excelInput = excelInput;
	}
	public String download() throws Exception{
		
		List<Map<String,String>> list=new LinkedList<Map<String,String>>();
		for(int i=0;i<10;i++){
			Map<String, String> map=new HashMap<String, String>();
			map.put("studentName", "name"+i);
			map.put("studentNumber", "number"+i);
			list.add(map);
		}
		ExcelModule excelModule = new ExcelModule(list);
		InputStream is=ExcelExpUtil.getExcelInputStream(excelModule,ExcelPathUtil.getExcelAbsolutePath("test.xls"));
		this.setExcelInput(is);
		return SUCCESS;
	}
	
}
